﻿using System;
using System.ServiceModel;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace BecktonService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        bool register(string email, string password);

        [OperationContract]
        bool connect(string email, string password);

        [OperationContract]
        bool addFriend(string email);

        [OperationContract]
        void removeFriend(string email);

        [OperationContract]
        List<string> getFriends();

        [OperationContract]
        int addDirectory(string dname, int parent = -1);

        [OperationContract]
        void shareDirectory(int directory, string friendEmail);

        [OperationContract]
        DirectoryTree getDirectoryTree();

        [OperationContract]
        DirectoryTree getFriendDirectoryTree(string friendEmail);

        /* [OperationContract]
         RemoteFileInfo DownloadFile(DownloadRequest request);*/
        
    }

    [DataContract]
    public class FileDesc
    {
        string name;
        string uri;
        int id;

        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        [DataMember]
        public string Uri
        {
            get { return uri; }
            set { uri = value; }
        }

        [DataMember]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
    }

    [DataContract]
    public class DirectoryTree
    {
        string name;
        int id;
        List<DirectoryTree> children;
        List<FileDesc> files;

        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        [DataMember]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        [DataMember]
        public List<DirectoryTree> Children
        {
            get { return children; }
            set { children = value; }
        }

        [DataMember]
        public List<FileDesc> Files
        {
            get { return files; }
            set { files = value; }
        }
    }

    /*

    [MessageContract]
    public class DownloadRequest
    {
        [MessageBodyMember]
        public string FileName;
    }
    
    [MessageContract]
    public class RemoteFileInfo : IDisposable
    {
        [MessageHeader(MustUnderstand = true)]
        public string FileName;

        [MessageHeader(MustUnderstand = true)]
        public long Length;

        [MessageBodyMember(Order = 1)]
        public System.IO.Stream FileByteStream;

        public void Dispose()
        {
            if (FileByteStream != null)
            {
                FileByteStream.Close();
                FileByteStream = null;
            }
        }
    }
     */
}